<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="所属类型" prop="typeId">
        <el-input
          v-model="queryParams.typeId"
          placeholder="请输入所属类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="户名" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入户名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="账户号" prop="accountNo">
        <el-input
          v-model="queryParams.accountNo"
          placeholder="请输入账户号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:cfile:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:cfile:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:cfile:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:cfile:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="showCreateFormOne"
        >提交
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="cfileList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="所属类型" align="center" prop="typeId" />
      <el-table-column label="户名" align="center" prop="userName" />
      <el-table-column label="账户号" align="center" prop="accountNo" />
      <el-table-column label="电子流水单" align="center" prop="serialNo" />
      <el-table-column label="开始时间" align="center" prop="startTime" />
      <el-table-column label="结束时间" align="center" prop="endTime" />
      <el-table-column label="总金额(收)" align="center" prop="totalInMoney" />
      <el-table-column label="总金额(支)" align="center" prop="totalOutMoney" />
      <el-table-column label="备注信息" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="openDownLoadBox(scope.row.id)"
            v-hasPermi="['system:cfile:edit']"
          >下载</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="resetUpdateData(scope.row)"
            v-hasPermi="['system:cfile:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:cfile:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改PDF文件生成记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="所属类型" prop="typeId">
          <el-input v-model="form.type" placeholder="请输入所属类型" />
        </el-form-item>
        <el-form-item label="户名" prop="userName">
          <el-input v-model="form.userName" placeholder="请输入户名" />
        </el-form-item>
        <el-form-item label="账户号" prop="accountNo">
          <el-input v-model="form.accountNo" placeholder="请输入账户号" />
        </el-form-item>
        <el-form-item label="电子流水单" prop="serialNo">
          <el-input v-model="form.serialNo" placeholder="请输入电子流水单" />
        </el-form-item>
        <el-form-item label="开始时间" prop="startTime">
          <el-input v-model="form.startTime" placeholder="请输入开始时间" />
        </el-form-item>
        <el-form-item label="结束时间" prop="endTime">
          <el-input v-model="form.endTime" placeholder="请输入结束时间" />
        </el-form-item>
        <el-form-item label="原始金额" prop="originalMoney">
          <el-input v-model="form.originalMoney" placeholder="请输入原始金额" />
        </el-form-item>
        <el-form-item label="明细总条数" prop="detailNums">
          <el-input v-model="form.detailNums" placeholder="请输入明细总条数" />
        </el-form-item>
        <el-form-item label="收入总条数" prop="inNum">
          <el-input v-model="form.inNum" placeholder="请输入收入总条数" />
        </el-form-item>
        <el-form-item label="总金额(收)" prop="totalInMoney">
          <el-input v-model="form.totalInMoney" placeholder="请输入总金额(收)" />
        </el-form-item>
        <el-form-item label="总金额(支)" prop="totalOutMoney">
          <el-input v-model="form.totalOutMoney" placeholder="请输入总金额(支)" />
        </el-form-item>
        <el-form-item label="收入明细" prop="inMoneyDetail">
          <el-input v-model="form.inMoneyDetail" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="支出明细" prop="outMoneyDetail">
          <el-input v-model="form.outMoneyDetail" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="pdf文件名称" prop="pdfFileName">
          <el-input v-model="form.pdfFileName" placeholder="请输入pdf文件名称" />
        </el-form-item>
        <el-form-item label="pdf文件下载地址" prop="pdfFileDownloadUrl">
          <el-input v-model="form.pdfFileDownloadUrl" placeholder="请输入pdf文件下载地址" />
        </el-form-item>
        <el-form-item label="备注信息" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 前置信息填写 -->
    <el-dialog title="前置信息设置" :visible.sync="openCreateFormOneFlag" width="60%" append-to-body>
      <el-form :model="createForm" ref="createForm" size="small" :inline="true" label-width="100px">
        <el-form-item label="类型" prop="type">
          <el-input
            v-model="createForm.type"
            placeholder="请输入类型"
            clearable
          />
        </el-form-item>
        <el-form-item label="开始时间" prop="startTime">
          <el-input
            v-model="createForm.startTime"
            placeholder="请输入开始时间"
            clearable
          />
        </el-form-item>
        <el-form-item label="结束时间" prop="endTime">
          <el-input
            v-model="createForm.endTime"
            placeholder="请输入结束时间"
            clearable
          />
        </el-form-item>
        <el-form-item label="户名" prop="userName">
          <el-input
            v-model="createForm.userName"
            placeholder="请输入户名"
            clearable
          />
        </el-form-item>
        <el-form-item label="账户号" prop="accountNo">
          <el-input
            v-model="createForm.accountNo"
            placeholder="请输入账户号"
            clearable
          />
        </el-form-item>
        <el-form-item v-if="createType == 'NH'" label="电子流水号" prop="serialNo">
          <el-input
            v-model="createForm.serialNo"
            placeholder="请输入电子流水号"
            clearable
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="showCreatFormTwo">确定</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="openCreateFormOneFlag = false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 明细生成回填 -->
    <el-dialog title="明细生成回填" :visible.sync="openCreateFormTwoFlag" width="75%" append-to-body>
      <div>
        <el-form ref="createFormTwo" :model="createForm" label-width="120px">
          <el-form-item label="原始余额：" prop="originalMoney" style="float: left">
            <el-input v-model="createForm.originalMoney" placeholder="请输入原始余额"/>
          </el-form-item>
          <el-form-item label="明细总条数：" prop="detailNums" style="float: left">
            <el-input v-model="createForm.detailNums" placeholder="请输入明细总条数"/>
          </el-form-item>
          <el-form-item label="收入总条数：" prop="inNum" style="float: left">
            <el-input v-model="createForm.inNum" placeholder="请输入收入总条数"/>
          </el-form-item>
          <el-form-item label="总金额(收)：" prop="totalInMoney" style="float: left">
            <el-input v-model="createForm.totalInMoney" placeholder="请输入总金额(收)"/>
          </el-form-item>
          <el-form-item label="总金额(支)：" prop="totalOutMoney" style="float: left">
            <el-input v-model="createForm.totalOutMoney" placeholder="请输入总金额(支)"/>
          </el-form-item>
          <el-button type="primary" style="margin-left: 15px" @click="createAndShow(createForm)">生成且回填
          </el-button>
          <div style="clear: both"></div>
          <div
            v-if="randomData.inValueList != undefined && randomData.inValueList != null && randomData.inValueList.length > 0">
            <span>处理后总额(收)：<span style="color: green; margin-right: 10px">{{ randomData.dealInTotalMoney }};</span> </span>
            <span>处理后总额(支)：<span style="color: red; margin-right: 10px">{{ randomData.dealOutTotalMoney }};</span> </span>
            <span>差值：<span style="color: orange">{{ randomData.dealInTotalMoney - randomData.dealOutTotalMoney }};</span> </span>
          </div>
        </el-form>
      </div>
      <div style="margin-top: 8px">
        <el-tabs v-model="activeName" tab-position="top" type="border-card" @tab-click="handleClick">
          <el-tab-pane :label="'收入明细 (' + randomData.inValueList.length + ')'" name="in">
            <el-table v-loading="editLoading" :data="randomData.inValueList" :cell-class-name="tableCellClassName"
                      @row-dblclick="dbclick">
              <el-table-column label="交易日期" align="center" prop="transactionDate">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionDate"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionDate }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易时间" align="center" prop="transactionTime">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionTime"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionTime }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易摘要" align="center" prop="transactionSummary">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionSummary"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionSummary }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易金额" align="center" prop="transactionMoneyInt">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionMoneyInt"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionMoneyInt }}</span>
                </template>
              </el-table-column>
              <el-table-column label="对手信息" align="center" prop="oppositionInformation">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.oppositionInformation"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.oppositionInformation }}</span>
                </template>
              </el-table-column>
              <el-table-column label="日志号" align="center" prop="logNo">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.logNo"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.logNo }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易渠道" align="center" prop="transactionChannels">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionChannels"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionChannels }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易附言" align="center" prop="transactionNote">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionNote"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionNote }}</span>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane :label="'支出明细 (' + randomData.outValueList.length + ')'" name="out">
            <el-table v-loading="editLoading" :data="randomData.outValueList" :cell-class-name="tableCellClassName"
                      @row-dblclick="dbclick">
              <el-table-column label="交易日期" align="center" prop="transactionDate">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionDate"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionDate }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易时间" align="center" prop="transactionTime">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionTime"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionTime }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易摘要" align="center" prop="transactionSummary">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionSummary"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionSummary }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易金额" align="center" prop="transactionMoneyInt">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionMoneyInt"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionMoneyInt }}</span>
                </template>
              </el-table-column>
              <el-table-column label="对手信息" align="center" prop="oppositionInformation">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.oppositionInformation"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.oppositionInformation }}</span>
                </template>
              </el-table-column>
              <el-table-column label="日志号" align="center" prop="logNo">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.logNo"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.logNo }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易渠道" align="center" prop="transactionChannels">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionChannels"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionChannels }}</span>
                </template>
              </el-table-column>
              <el-table-column label="交易附言" align="center" prop="transactionNote">
                <template slot-scope="scope">
                  <el-input
                    v-if="scope.row.index + ',' + scope.column.index == currentCell"
                    :ref="scope.row.index + ',' + scope.column.index"
                    v-model="scope.row.transactionNote"
                    @blur="hideInput(scope.row)"
                  />
                  <span v-else>{{ scope.row.transactionNote }}</span>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dealRandomDataToFile">确 定</el-button>
        <el-button @click="openCreateFormTwoFlag = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listCfile, getCfile, delCfile, addCfile, updateCfile } from "@/api/system/cfile";
import {createFileByData, getDealedValueList, getDetailValueList} from "@/api/system/file";

export default {
  name: "Cfile",
  dicts: ['align_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // PDF文件生成记录表格数据
      cfileList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      createType: "NH",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        typeId: null,
        userName: null,
        accountNo: null,
        serialNo: null,
        startTime: null,
        endTime: null,
        originalMoney: null,
        detailNums: null,
        inNum: null,
        totalInMoney: null,
        totalOutMoney: null,
        inMoneyDetail: null,
        outMoneyDetail: null,
        pdfFileName: null,
        pdfFileDownloadUrl: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      createForm: {
        createFileId: null,
        typeId: null,
        detailNums: null,
        startTime: null,
        endTime: null,
        originalMoney: null,
        inNum: null,
        totalInMoney: null,
        totalOutMoney: null,
        userName: null,
        accountNo: null,
        serialNo: null,
        inValueList: [],
        outValueList: [],
      },
      openCreateFormOneFlag: false,
      openCreateFormTwoFlag: false,
      randomData: {
        inValueList: [],
        outValueList: [],
        dealInTotalMoney: 0,
        dealOutTotalMoney: 0
      },
      editLoading: false,
      activeName: 'in',
      currentCell: null,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询PDF文件生成记录列表 */
    getList() {
      this.loading = true;
      listCfile(this.queryParams).then(response => {
        this.cfileList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        typeId: null,
        userName: null,
        accountNo: null,
        serialNo: null,
        startTime: null,
        endTime: null,
        originalMoney: null,
        detailNums: null,
        inNum: null,
        totalInMoney: null,
        totalOutMoney: null,
        inMoneyDetail: null,
        outMoneyDetail: null,
        pdfFileName: null,
        pdfFileDownloadUrl: null,
        createTime: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加PDF文件生成记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      this.$set(this.createForm, 'createFileId', row.id);
      getCfile(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改PDF文件生成记录";
      });
    },
    resetUpdateData(row) {
      this.createForm = row;
      this.$set(this.createForm, 'createFileId', row.id);
      this.$set(this.createForm, 'inValueList', JSON.parse(row.inMoneyDetail));
      this.$set(this.createForm, 'outValueList', JSON.parse(row.outMoneyDetail));
      this.openCreateFormOneFlag = true;
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateCfile(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCfile(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除PDF文件生成记录编号为"' + ids + '"的数据项？').then(function() {
        return delCfile(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/cfile/export', {
        ...this.queryParams
      }, `cfile_${new Date().getTime()}.xlsx`)
    },
    showCreateFormOne() {
      this.openCreateFormOneFlag = true;
    },
    showCreatFormTwo() {
      // 校验必填是否为空，
      if (this.createForm.createFileId != null && this.createForm.createFileId != '' && this.createForm.createFileId != undefined) {
        this.$set(this.randomData, 'inValueList', this.createForm.inValueList);
        this.$set(this.randomData, 'outValueList', this.createForm.outValueList);
        this.calcTotalMoney();
      }
      this.openCreateFormTwoFlag = true;
      this.openCreateFormOneFlag = false;
    },
    createAndShow(row) {
      getDetailValueList(row).then(res => {
        this.randomData = res.data;
        this.hideInput(this.randomData.inValueList[0]);
        this.hideInput(this.randomData.outValueList[0]);
      })
    },
    dealRandomDataToFile() {
      this.$set(this.createForm, 'inValueList', this.randomData.inValueList);
      this.$set(this.createForm, 'outValueList', this.randomData.outValueList);
      createFileByData(this.createForm).then(res => {
        if (res.code === 200) {
          this.getList();
          this.openCreateFormTwoFlag = false;
          this.$modal.msgSuccess("文件处理成功！");
        } else {
          this.$modal.msgError("文件处理失败！");
        }
      })
    },
    handleClick(tab, event) {
      console.log(tab, event);
      this.activeName = tab.name;
      this.hideInput(this.randomData.inValueList[0]);
      this.hideInput(this.randomData.outValueList[0]);
    },
    // 给单元格绑定横向和竖向的index，这样就能确定是哪一个单元格
    tableCellClassName({row, column, rowIndex, columnIndex}) {
      row.index = rowIndex;
      column.index = columnIndex;
    },
    // 获得当前双击的单元格的横竖index，然后拼接成一个唯一字符串用于判断，并赋给currentCell
    // 拼接后类似这样："1,0","1,1",
    dbclick(row, column) {
      this.currentCell = row.index + ',' + column.index;
      // input 自动获取焦点
      // 双击后自动获得焦点
      this.$nextTick(() => {
        this.$refs[row.index + ',' + column.index].focus()
      })
      /*if (column.property === 'transactionMoneyInt') {

      }*/
    },
    // 关闭编辑状态
    hideInput(row) {
      this.currentCell = null
      this.calcTotalMoney();
    },
    calcTotalMoney() {
      let inTotal = this.randomData.inValueList.reduce((sum, e) => sum + Number(e.transactionMoneyInt || 0), 0);
      let outTotal = this.randomData.outValueList.reduce((sum, e) => sum + Number(e.transactionMoneyInt || 0), 0);
      this.$set(this.randomData, 'dealInTotalMoney', inTotal);
      this.$set(this.randomData, 'dealOutTotalMoney', Math.abs(outTotal));
    },
    openDownLoadBox(fileId) {
      this.$confirm('点击下载文件', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'success'
      }).then(() => {
        this.downLoadFile(fileId);
      });
    },
    // 下载处理完成的文件
    downLoadFile(fileId) {
      this.$download.downloadDealFile(fileId).then(res => {
        this.$modal.msgSuccess("文件下载中,请稍等...");
      })
    },
  }
};
</script>
